<%
CheckSession()
straddoredit=Request.QueryString("addoredit")
strsaveitem=Request.Form("saveitem")
deletepic=Request.QueryString("deletepic")
'pic1=Request.Form("pic1")
'pic2=Request.Form("pic2")
onoffPic=Request.Form("addpic")
if (onoffPic="") then
onoffPic=Request.QueryString("addpic")
end if
'---DELETE ITEM---------------------------------
if straddoredit = "deleteitem" then
strID=Request.QueryString("option")
'Find pics for ID
mySQL="SELECT Pic1, Pic2 FROM ShowcaseItems WHERE ID = " &strID& ""
set conntemp=server.createobject("adodb.connection")
conntemp.ConnectionTimeout = 20
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
DO UNTIL rstemp.eof
For each whatever in rstemp.fields
Select case whatever.name
case "Pic1"
strPic1=whatever.value
case "Pic2"
strPic2=whatever.value
End select
Next
rstemp.movenext
LOOP
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
'Delete Pictures from Folder
Dim file1, file2
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
file1 = ItemPicPath+strPic1
file2 = ItemPicPath+strPic2
if (strPic1<>"") then
if (objFSO.FileExists(file1)=true) then
response.write "FileExists"
objFSO.DeleteFile file1, True
end if
end if
if (strPic2<>"") then
if (objFSO.FileExists(file2)=true) then
objFSO.DeleteFile file2, True
end if
end if
Set objFSO = Nothing
'Delete Record from Database
mySQL="DELETE FROM "&ItemTable&" WHERE ID="&strID
'response.write mySQL
ExecuteSQL(mySQL)
Response.Redirect "dispopt.asp"
response.end
end if
'---SAVE ITEM THAT HAS BEEN EDITED---------------------
if strsaveitem = "save" then
userID=session("userid")
strID=Request.Form("Option")
strDescrip=ReplaceQuotes(Request.Form("Description"))
strTitle=ReplaceQuotes(Request.Form("Title"))
strAge=Request.Form("Age")
strShowcaseCategoryID=Request.Form("Categories")
if (Request.Form("Price")<>"") then
strPrice=CSng(Request.Form("Price"))
else
strPrice=0
end if
strSold=Request.Form("Sold")
strInclShipping=Request.Form("InclShipping")
if strInclShipping="on" then
strInclShipping="1"
else
strInclShipping="0"
end if
strPic1=ReplaceQuotes(Request.Form("Pic1"))
strPic2=ReplaceQuotes(Request.Form("Pic2"))
'strExpDate=Request.Form("month")
'strExpDate=strExpDate+"-"+Request.Form("year")
If checkspace(strDescrip) then
Response.write "Please go back and enter a Description."
response.end
elseif checkspace(strTitle) then
Response.write "Please go back and enter a Title."
response.end
else
If strID="" then 'If no item selected, this is for adding a NEW item.
str1 = month(Date)
str2 = day(date)
str3 = year(date)
datestrs = str3 & "-" & str1 & "-" & str2
mySQL="INSERT INTO "&ItemTable&" (SubmitDate, ShowcaseUserID, Title, Age, ShowcaseCategoryID, Description, Sold, Price, ShippingDisplay) VALUES ('" &datestrs& "', "&userID&", '" &strTitle& "', '" &strAge& "', " &strShowcaseCategoryID& ", '" &strDescrip& "', "&strSold&", '" &strPrice& "', "&strInclShipping&")"
'response.write mySQL&" "
'response.end
ExecuteSQL(mySQL)
'Now find the ID of the question record you just created.
mySQL="SELECT MAX(ID) AS maxid FROM ShowcaseItems;"
set conntemp=server.createobject("adodb.connection")
conntemp.mode = 3
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
strID=rstemp.fields("maxid").Value
set rstemp=nothing
conntemp.Close
set conntemp=nothing
'response.write "ID="&NewID&" "
Else 'If there is an item selected, this is for updating an item.
mySQL="UPDATE "&ItemTable&" SET Title='" &strTitle& "', Age='" &strAge& "', ShowcaseCategoryID=" &strShowcaseCategoryID& ", Description='" &strDescrip& "', Sold= "&strSold&", Price=" &strPrice& ", ShippingDisplay="&strInclShipping&" WHERE ID=" &strID& ""
'response.write mySQL&" "
'response.end
ExecuteSQL(mySQL)
End if
session("itemID") = strID
End if
if onoffPic = "" then
Response.Redirect "dispopt.asp"
response.end
end if
End if
'---ADD PIC -------------------------------------
if onoffPic = "on" then
if strID="" then
strID=session("itemID")
end if
'Find pics for ID
dim picArray(2)
mySQL="SELECT Pic1, Pic2 FROM "&ItemTable&" WHERE ID = " &strID& ""
set conntemp=server.createobject("adodb.connection")
conntemp.ConnectionTimeout = 20
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
DO UNTIL rstemp.eof
For each whatever in rstemp.fields
Select case whatever.name
case "Pic1"
picArray(1)=whatever.value
case "Pic2"
picArray(2)=whatever.value
End select
Next
rstemp.movenext
LOOP
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
if deletepic="yes" then
picNo=Request.QueryString("picNo")
'Make picNo for ID = ''
mySQL="UPDATE "&ItemTable&" SET Pic"&picNo&"='' WHERE ID = " &strID& ""
ExecuteSQL(mySQL)
'Delete the picture
Dim file
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
file = ItemPicPath+picArray(picNo)
if objFSO.FileExists (file) then
'response.write "File deleted: "&file
objFSO.DeleteFile file, True
end if
Set objFSO = Nothing
picArray(picNo)=""
end if
response.write ""
response.write "Any changes to your item have been saved.
| "
response.write " "+vbcrlf
response.write ""+vbcrlf
For i=1 to UBound(picArray)
response.write "Pic "&i&": "+vbcrlf
picform=""+vbcrlf
if (picArray(i)<> "") then
response.write "Change Image | Delete Image
"+vbcrlf
response.write picform
response.write " "
response.write ""+vbcrlf
else
response.write "Add Image "+vbcrlf
response.write picform
end if
response.write "
"
Next
response.write " | "
response.write "Back to Item Listing | Back to Main Page | "
response.write " "
response.end
end if
'---EDIT ITEM---------------------------------
if straddoredit = "edititem" then
'Get Item information
numOption=Request.QueryString("Option")
mySQL="SELECT * FROM "&ItemTable&" WHERE ID = " &numOption& ""
set conntemp=server.createobject("adodb.connection")
conntemp.ConnectionTimeout = 20
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
DO UNTIL rstemp.eof
For each whatever in rstemp.fields
Select case whatever.name
case "SubmitDate"
strSubmitDate=whatever.value
case "Title"
strTitle=whatever.value
case "Age"
strAge=whatever.value
case "ShowcaseCategoryID"
strCategoryID=whatever.value
case "Description"
strDescription=whatever.value
case "Price"
strPrice=FormatCurrency(whatever.value,2)
case "Pic1"
strPic1=whatever.value
case "Pic2"
strPic2=whatever.value
case "Sold"
strSold=whatever.value
case "ShippingDisplay"
strInclShipping=whatever.value
End select
Next
rstemp.movenext
LOOP
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end if
if strSubmitDate="" then
strSubmitDate=Date
end if
response.write " "
%>
|
|